<template>
  <router-view />
  <van-tabbar route>
    <van-tabbar-item to="/home" icon="home-o">主页</van-tabbar-item>
    <van-tabbar-item to="/categoylist" icon="home-o">分类</van-tabbar-item>
    <van-tabbar-item to="/car" icon="cart-o">购物车</van-tabbar-item>
    <van-tabbar-item to="/login" icon="manager-o" v-if="!isLogin"
      >登录</van-tabbar-item
    >
    <van-tabbar-item to="/user" icon="manager-o" v-else>用户中心</van-tabbar-item>
  </van-tabbar>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import type { Ref } from "vue";
import { useUserInfoStore } from "../stores/userInfo";


//  根据用户是否有token来判断用户应该显示登录入口还是显示用户中心
//  用户登录 -> 回到首页 -> 给token赋值 -> 更改导航栏
const activeRouter: Ref<number> = ref(0);
const isLogin: Ref<boolean> = ref(false);
const store = useUserInfoStore();

onMounted(() => {
  isLogin.value = Boolean(store.getUserData?.token);
});
</script>

<style lang='scss' scoped></style>
